Fix auto-recovery behavior for AMQ119002 producer failures#564
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adjusts auto-recovery behavior for producers when the broker closes a producer link with terminal AMQP error conditions (notably AMQ119002 / amqp:not-found), preventing repeated recovery attempts that can flood logs.
Changes:
- Treat
ProducerClosedExceptionwithErrorCode.NotFound(andUnauthorizedAccess) as terminal forAutoRecoveringProducerby terminating the producer instead of retrying/recovering. - Treat
UnauthorizedAccessas terminal forAutoRecoveringAnonymousProducerby terminating the anonymous producer instead of retrying. - Add unit tests covering terminal close behavior for producer send/send-async and anonymous producer send/send-async.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| test/ArtemisNetClient.UnitTests/AutoRecovering/AutoRecoveringProducerSpec.cs | Adds tests asserting producers terminate (no further retries) when the producer link is closed with amqp:not-found (AMQ119002). |
| test/ArtemisNetClient.UnitTests/AutoRecovering/AutoRecoveringAnonymousProducerSpec.cs | New tests asserting anonymous producers terminate when link is closed with amqp:unauthorized-access. |
| src/ArtemisNetClient/AutoRecovering/AutoRecoveringProducer.cs | Terminates the auto-recovering producer for terminal broker-side close reasons (UnauthorizedAccess, NotFound) instead of retrying. |
| src/ArtemisNetClient/AutoRecovering/AutoRecoveringAnonymousProducer.cs | Terminates the auto-recovering anonymous producer on UnauthorizedAccess instead of retrying. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| var host = CreateOpenedContainerHost(); | ||
| var linkProcessor = host.CreateTestLinkProcessor(); | ||
|
|
There was a problem hiding this comment.
CreateOpenedContainerHost() opens a listening TestContainerHost, but this test doesn't dispose it. Please ensure host is disposed (e.g., using var host = ...) to avoid leaking resources/ports between tests.
There was a problem hiding this comment.
Fixed both test methods (Should_not_retry_SendAsync_when_producer_link_closed_with_not_found and Should_not_retry_Send_when_producer_link_closed_with_not_found) to use using var host = CreateOpenedContainerHost() for proper disposal. Commit: b25ba1c
| [Fact] | ||
| public async Task Should_not_retry_SendAsync_when_producer_link_closed_with_not_found() | ||
| { | ||
| var host = CreateOpenedContainerHost(); |
There was a problem hiding this comment.
CreateOpenedContainerHost() opens a listening TestContainerHost, but this test never disposes it. Please wrap host in using (or dispose via DisposeUtil) to avoid leaking listeners across the test run.
| var host = CreateOpenedContainerHost(); | |
| using var host = CreateOpenedContainerHost(); |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| catch (ProducerClosedException e) when (IsTerminalProducerException(e)) | ||
| { | ||
| await TerminateAsync(e).ConfigureAwait(false); |
| catch (ProducerClosedException e) when (e.ErrorCode is ErrorCode.UnauthorizedAccess) | ||
| { | ||
| await TerminateAsync(e).ConfigureAwait(false); |
| catch (ProducerClosedException e) when (IsTerminalProducerException(e)) | ||
| { | ||
| TerminateAsync(e).GetAwaiter().GetResult(); |
| } | ||
| catch (ProducerClosedException e) when (e.ErrorCode is ErrorCode.UnauthorizedAccess) | ||
| { | ||
| TerminateAsync(e).GetAwaiter().GetResult(); |
|
@copilot apply changes based on the comments in this thread |
Fixed in commit 35efb24. Added tests for both the regular producer ( |
35efb24 to
a61042b
Compare
|
@copilot apply changes based on the comments in this thread |
That change was already applied in commit |
b8102a3 to
47261c6
Compare
Agent-Logs-Url: https://github.com/Havret/dotnet-activemq-artemis-client/sessions/9fa39fcb-f6d4-4ec4-92ea-543ba4755994 Co-authored-by: Havret <9103861+Havret@users.noreply.github.com>
…rom recovery set Agent-Logs-Url: https://github.com/Havret/dotnet-activemq-artemis-client/sessions/8bc2f1b9-864e-4a9f-a756-be8df181d7e6 Co-authored-by: Havret <9103861+Havret@users.noreply.github.com>
47261c6 to
0f12d8f
Compare
Fixes #562